package basic.thread.student;

public class GetStudentThread implements Runnable{

	private Student student ;
	private int x;
	
	public GetStudentThread(Student student){
		
		this.student = student;
	}
	@Override
	public void run() {
		while(x<20){
			synchronized (student) {
				if (!student.flag) {
					try {
						student.wait();
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
				System.out.println(student.getName()+"   "+student.getAge());
				x++;
				student.flag=false;
				student.notify();
			}
		}
		System.out.println("x="+x);
	}

}
